home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / textst.zip / TEXTST.PRG < prev   
Text File  |  1993-04-12  |  2KB  |  78 lines

  1. program Textst;  {text file, sort then save to disk.}
  2.    uses crt, dos;
  3.  
  4. const
  5.    TextSize   = 500;                                    {Mod. #1}
  6.    LineLength = 80;                                     {Mod. #1}
  7.  
  8. type
  9.    LineSize = string[LineLength];
  10.    String80 = string[80];
  11.    TextArrayType = array[1..TextSize] of LineSize;
  12.  
  13. var
  14.    TextArray                        : TextArrayType;
  15.    LineCount, Code, Position, Width : integer;
  16.    CharEntry                        : char;
  17.    FileSpec                         : String80;
  18.  
  19. {$I GetNumI.PSL}
  20. {$I LoadTxt.PSL}
  21. {$I SaveTxt.PSL}
  22. {$I ShowDir.PSL}
  23. {$I SortHT.PSL}
  24.  
  25. BEGIN
  26.    clrscr;
  27.    writeln('**** SortText Program ****');
  28.    writeln;
  29.    writeln('Maximum text lines that can be sorted = ', TextSize);
  30.    writeln('Maximum length of each text line = ', LineLength);
  31.    writeln;
  32.    writeln('For the sort key:');
  33.    writeln;
  34.    repeat
  35.       writeln('Enter the position number it starts in.');
  36.       GetNumI(Position, CharEntry, Code);
  37.       if (Position < 1) or (Position > 255) then
  38.          Code := -3;
  39.       if Code <> 0 then
  40.          writeln(#7, '** Illegal entry **')
  41.    until
  42.       Code = 0;
  43.    writeln;
  44.    repeat
  45.       writeln('Enter the sort key length.');
  46.       GetNumI(Width, CharEntry, Code);
  47.       if (Width < 1) or (Width > 255) then
  48.          Code := -4;
  49.       if Code <> 0 then
  50.          writeln(#7, '** Illegal entry **')
  51.    until
  52.       Code = 0;
  53.    writeln;
  54.    writeln;
  55.    FileSpec := '*.*';                                   {Mod. #2}
  56.    writeln('Files in current active directory are');    {Mod. #2}
  57.    ShowDir(FileSpec, 0);
  58.    writeln;
  59.    LineCount := 0;
  60.    LoadTxt(TextArray, LineCount, Code);
  61.    if Code <> 0 then
  62.       begin
  63.          writeln('** Program aborted **');
  64.          halt
  65.       end;
  66.    SortHT(TextArray, LineCount, Position, Width);
  67.    writeln;
  68.    writeln(LineCount, ' lines of text sorted');
  69.    writeln;
  70.    SaveTxt(TextArray, LineCount, Code);
  71.    writeln;
  72.    if Code <> 0 then
  73.       writeln('Unsuccessful file save.')
  74.    else
  75.       writeln('Sorted file successfully saved');
  76.    writeln
  77. END.
  78.